package com.broadsoft.platform.wfengine.helper;

import com.broadsoft.platform.wfengine.DecisionType;
import com.broadsoft.platform.wfengine.EndNodeType;
import com.broadsoft.platform.wfengine.ExternalNodeType;
import com.broadsoft.platform.wfengine.GeneralNodeType;
import com.broadsoft.platform.wfengine.JoinType;
import com.broadsoft.platform.wfengine.NodeType;
import com.broadsoft.platform.wfengine.SplitType;
import com.broadsoft.platform.wfengine.StartNodeType;
import com.broadsoft.platform.wfengine.SubflowType;
import com.broadsoft.platform.wfengine.exception.WfException;

/**
 * 
* FIXME: <A few lines of description of what class is about and what it does.> 
*
* <HR/><B>Modification Block</B>
* <P>
* Version: FIXME: 1.0.1 <BR>
* Author: FIXME: luzhen
* Date: 2011-9-15
* TAG: <A short name to find out all changed made by this modification.>
* Comments: Created.
* Bug fix NO.: <If required>
* </P>
* <P>
* ... Other Modifications following above structure.
* </P>
*
 */
public class NodeTypeHelper implements WfConstants{

    
    public static int getTypeOfNode(NodeType currentNode){
        int type=0;
        
        if(currentNode instanceof StartNodeType){
            return START_NODE;
        } 
        if(currentNode instanceof DecisionType){
            return DECISION_NODE;
        } 
        
        if(currentNode instanceof EndNodeType){
            return END_NODE;
        }  
        
        if(currentNode instanceof ExternalNodeType){
            return EXTERNAL_NODE;
        }  
        
        if(currentNode instanceof SplitType){
            return SPLIT_NODE;
        } 
        
        if(currentNode instanceof JoinType){
            return JOIN_NODE;
        } 
        
        if(currentNode instanceof SubflowType){
            return SUB_FLOW;
        }  
        
        if(currentNode instanceof GeneralNodeType){
            return GENERAL_NODE;
        } 
        throw new WfException("The node["+currentNode.getClass()+"] is not valid node."); 
    }//end of getTypeOfNode
}
